package com.tcc.qa.test.util;

import org.apache.xpath.operations.String;
import org.openqa.jetty.html.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class LinkFinder {
  public static WebElement getLinkById(WebDriver driver, String id) {
    return driver.findElement(By.id(id));
  }
	public static WebElement getLinkByText(WebDriver driver, String name) {
		return driver.findElement(By.linkText(name));
	}

	public static WebElement getLinkByText(WebDriver driver, String name,
			String contains) {
		List<WebElement> eles = driver.findElements(By
				.xpath("//a[contains(@href,'" + contains + "')]"));
		for (WebElement e : eles) {

			if (e.getText().equals(name)) {
				return e;
			}
		}
		return null;
	}
}
